package com.cast.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cast.health.pojo.CheckGroup;
import com.cast.health.pojo.CheckItem;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CheckGroupMapper extends BaseMapper<CheckGroup> {

    //SELECT checkitem_id FROM t_checkgroup_checkitem WHERE checkgroup_id=

    //通检查组的id查询中间表当中对应的检查项id,再得到通过得到的检查项id得到检查项的所有数据
    @Select("SELECT * FROM t_checkitem WHERE id in (SELECT checkitem_id FROM t_checkgroup_checkitem WHERE checkgroup_id= #{id}) ")
    List<CheckItem> selectByCheckItemIds(@Param("id") Integer id);

    //INSERT INTO t_checkgroup_checkitem (checkgroup_id,checkitem_id) VALUES (16,36)

    //添加检查项和检查组的中间表
    @Insert("INSERT INTO t_checkgroup_checkitem (checkgroup_id,checkitem_id) VALUES (#{id},#{idItem})")
    int addItemAndGroup(@Param("id") Integer id, @Param("idItem") Integer idItem);
}
